﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ChineseSchool.BLL;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool.UserControl
{
    public partial class Activities : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblActivities.Text = LoadActivities();
            }

        }

        public string LoadActivities()
        {
            string strActivities = "";
            List<M_Activities> lstActivities = new B_Activities().GetAlls(8);            
            if (lstActivities != null && lstActivities.Count > 0)
            {
                for (int i = 0; i < lstActivities.Count; i++)
                {
                    string day_class = "";
                    string dayofweek = lstActivities[i].ActivitiesDate.DayOfWeek.ToString();
                    switch (dayofweek)
                    {
                        case "Monday":
                            day_class = "mon";
                            break;
                        case "Tuesday":
                            day_class = "tue";
                            break;
                        case "Wednesday":
                            day_class = "wed";
                            break;
                        case "Thursday":
                            day_class = "thu";
                            break;
                        case "Friday":
                            day_class = "fri";
                            break;
                        case "Saturday":
                            day_class = "sat";
                            break;
                        case "Sunday":
                            day_class = "sun";
                            break;
                        default:
                            day_class = "mon";
                            break;
                    }
                    
                    strActivities += "<div class=\"activities\"> ";
                    strActivities += "<div class=\"tag " + day_class + "\"> ";
                    strActivities += "<a href=\"" + Util.MakeLinkActivitiesDetail(lstActivities[i].ActivitiesID.ToString(), Encode.Uni2KD(lstActivities[i].ActivitiesTitle.ToString())) + "\">" + lstActivities[i].ActivitiesDate.ToString("dd/MM/yyyy") + "</a></div>";
                    strActivities += "<a href=\"" + Util.MakeLinkActivitiesDetail(lstActivities[i].ActivitiesID.ToString(), Encode.Uni2KD(lstActivities[i].ActivitiesTitle.ToString())) + "\">" + lstActivities[i].ActivitiesTitle.ToString() + "</a>";
                    strActivities += "</div> ";
                }
            }
            return strActivities;
        }
    }
}